package org.example.person;

import org.example.models.abstracts.AbstractLiving;
import org.example.models.interfaces.own.Ownable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class Person extends AbstractLiving {
    private final int height;
    private final int weight;



    public Person(String name, int age, int height, int weight, List<Ownable> ownables) {
        super(name, age, ownables);
        this.height = height;
        this.weight = weight;
    }

    public Person(String name, int age, int height, int weight) {
        this(name, age, height, weight, new ArrayList<>());
    }
    public int getHeight() {
        return height;
    }

    public int getWeight() {
        return weight;
    }



    @Override
    public String toString() {
        return String.format("Person %s[age=%d, height=%d, weight=%d]", getName(), getAge(), getHeight(), getWeight());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Person person)) return false;
        return getAge() == person.getAge() && getHeight() == person.getHeight() && getWeight() == person.getWeight() && Objects.equals(getName(), person.getName());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getName(), getAge()*31, getHeight()*41, getWeight()*71);
    }

    @Override
    public void update(Object message) {
        describeAction(message.toString());
    }

}
